package com.myapp.api.service.impl;

import com.myapp.api.entity.Teacher;
import com.myapp.api.mapper.TeacherMapper;
import com.myapp.api.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper mapper;

    @Override
    public List<Teacher> getTeachers() {
        return mapper.getTeachers();
    }

    @Override
    public Teacher getTeacherById(@Param("id") Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public Teacher getTeacherByTid(@Param("tid") String tid) {
        return mapper.getTeacherByTid(tid);
    }

    @Override
    public Integer getTeacherByOneTid(@Param("tid") String tid) {
        return mapper.getTeacherByOneTid(tid);
    }

    @Override
    public List<Teacher> getTeacherByTname(@Param("tname") String tname) {
        return mapper.getTeacherByTname( tname );
    }

    @Override
    public int addTeacher(@Param("record") Teacher record) {
        return mapper.insertSelective(record);
    }

    @Override
    public int deleteTeacherById(@Param("id") Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int putTeacher(@Param("record") Teacher record) {
        return mapper.updateByPrimaryKeySelective(record);
    }
}
